<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>货品管理</title>
    <!-- bootstrap和hdjs引入 -->
    <link rel="stylesheet" href="__STATIC__/bootstrap/css/bootstrap.min.css" />
    <script type="text/javascript" src="__STATIC__/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="__STATIC__/hdjs/hdjs.min.js"></script>
    <link rel="stylesheet" href="__STATIC__/hdjs/hdjs.css" />
    <style type="text/css">
        .plus_minus{
            width: 20px;
        }
    </style>
    <script type="text/javascript">
    $(function(){

        $('.baocun').click(function() {
            var gid = $('#goodsGid').val();
            var color = $('#color').val();
            var size = $('#size').val();
            var inventery = $("input[name=inventery]").val();
            var number = $('input[name=number]').val();
            $.ajax({
                url:"{|U:'Admin/ShopGoodsList/add'}",
                data:{color:color,size:size,inventery:inventery,number:number,gid:gid},
                type:'post',
                dataType:'json',
                success:function(data){
                    var ww = new Array();
                        ww = data.combine.split(",");

                    var str = '';
                    str +='<tbody>';
                    str +='<td width="30"></td>';
                    str +='<td>'+data.shop_goods_gid+'</td>';
                    str +='<td>'+ww[0]+'</td>';
                    str +='<td>'+ww[1]+'</td>';
                    str +='<td>'+data.inventery+'</td>';
                    str +='<td>'+data.number+'</td>';
                    str +='<td width="200">';
                    str +=    '<a href="" class="hd-btn hd-btn-primary hd-btn-sm">修改</a>';
                    str +=    '<a href="" class="hd-btn hd-btn-danger hd-btn-sm">删除</a>';
                    str +='</td>';
                    str +='</tbody>';
                    // alert(str);
                    $('.strr').prepend(str);
                    $('#color').val('');
                    $('#size').val('');
                    $('input[name=inventery]').val('');
                    $('input[name=number]').val('');
                }



            })
        });
    })

    </script>
</head>
<body>
<div class="wrap">
    <table class="hd-table hd-table-list strr">
        <thead>
        <tr>
            <td width="30"></td>
            <td>货品id</td>
            <td>颜色</td>
            <td>尺码</td>
            <td>库存</td>
            <td>货号</td>
            <td width="200">操作</td>
        </tr>
        </thead>
        <tbody>
        <foreach from="$goodsData" key="$k" value="$v">
            <tr>
                <td width="30"></td>
                <td>{$v.glid}</td>
                <td>{$v.combine.0}</td>
                <td>{$v.combine.1}</td>
                <td>{$v.inventery}</td>
                <td>{$v.number}</td>
                <td width="200">
                    <a href="{|U:'Admin/ShopGoodsList/edit',array('glid'=>$v['glid'],'gid'=>$v['shop_goods_gid'])}" class="hd-btn hd-btn-primary hd-btn-sm">修改</a>
                    <a href="{|U:'Admin/ShopGoodsList/del',array('glid'=>$v['glid'],'gid'=>$v['shop_goods_gid'])}" class="hd-btn hd-btn-danger hd-btn-sm">删除</a>
                </td>
            </tr>
        </foreach>
        </tbody>
        <form action="javascript:;" method="post" class="goodslist">
        <tbody id="dd">
            <td width="30"></td>
            <td>添加货品</td>
            <td>
                <select name="spec[]" id="color" style="height:30px;width:100px">
                    <option value="0">-请选择-</option>
                    <foreach from="$color" key="$k" value="$v">
                        <option value="{$v.gtid}">{$v.gtvalue}</option>
                    </foreach>
                </select>
            </td>
            <td>
                <select name="spec[]" id="size" style="height:30px;width:100px">
                    <option value="0">-请选择-</option>
                    <foreach from="$size" key="$k" value="$v">
                        <option value="{$v.gtid}">{$v.gtvalue}</option>
                    </foreach>
                </select>
            </td>
            <td>
                <input type="text" name="inventery" style="height:30px;width:100px"/>
            </td>
            <td>
                <input type="text" name="number" style="height:30px;width:100px"/>
            </td>
            <td>
            <input type="hidden" value="{$hd.get.gid}" id="goodsGid"/>
            <a href="javascript:;" class="hd-btn hd-btn-danger hd-btn-sm baocun">保存添加</a>
            </td>
        </tbody>
        </form>
    </table>
    <div class="page_hdjob">
        
    </div>
</div>

</body>
</html>


